﻿<UserControl x:Class="Illusion.Sample.WPFControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:sample="clr-namespace:Illusion.Sample"
             mc:Ignorable="d" Width="263" Height="367"
             d:DesignWidth="260" TextOptions.TextFormattingMode="Display"
             d:DataContext="{d:DesignInstance {x:Type sample:ControlViewModel1}}">
    <UserControl.Resources>
        <sample:HashCodeConverter x:Key="HashCodeConverter" />
        <Style TargetType="ListBoxItem">
            <Setter Property="Height" Value="12" />
            <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        </Style>
    </UserControl.Resources>
    <Grid UseLayoutRounding="True">
        <TabControl x:Name="TabControl" 
                    SelectedIndex="{Binding Source={x:Static sample:DataWarehouse.Instance}, Path=SelectedIndex, Mode=TwoWay}">
            <TabControl.Items>
                <TabItem Header="Common Controls">
                    <Grid>
                        <CheckBox Content="CheckBox" HorizontalAlignment="Left" Margin="11,3,0,0" VerticalAlignment="Top" 
                  IsChecked="{Binding Path=CheckBoxValue}"/>
                        <ComboBox HorizontalAlignment="Left" Margin="11,23,0,0" VerticalAlignment="Top" Width="120"
                  ItemsSource="{Binding Path=ComboBoxValues}"
                  SelectedIndex="{Binding Path=ComboBoxSelectedIndex, Mode=TwoWay}"/>
                        <RadioButton Content="RadioButton1" HorizontalAlignment="Left" Margin="11,51,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.205,-0.176"
                     IsChecked="{Binding Path=IsRadioButton1Selected, Mode=TwoWay}"/>
                        <RadioButton Content="RadioButton2" HorizontalAlignment="Left" Margin="11,72,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.205,-0.176"
                     IsChecked="{Binding Path=IsRadioButton2Selected, Mode=TwoWay}"/>
                        <TextBox HorizontalAlignment="Left" Height="23" Margin="11,99,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"
                                 Text="{Binding Path=TextBoxText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                        <Slider HorizontalAlignment="Left" Margin="11,132,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.417,-0.136" Width="120"
                                Minimum="{Binding Path=SliderMinValue}" Maximum="{Binding Path=SliderMaxValue}" Value="{Binding Path=SliderValue}"
                                IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight"/>
                        <TabControl HorizontalAlignment="Left" Height="100" Margin="11,160,0,0" VerticalAlignment="Top" Width="205"
                                    ItemsSource="{Binding Path=Persons}" SelectedItem="{Binding Path=CurrentPerson, Mode=TwoWay}"
                                    DisplayMemberPath="Name" SelectedIndex="{Binding Path=TabControlSelectedIndex, Mode=TwoWay}">
                            <TabControl.ContentTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <TextBox Height="20" Width="100" Text="{Binding Path=Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                 HorizontalAlignment="Left" VerticalAlignment="Top"/>
                                    </Grid>
                                </DataTemplate>
                            </TabControl.ContentTemplate>
                        </TabControl>
                        <ScrollBar HorizontalAlignment="Left" Width="205" Margin="11,307,0,0" VerticalAlignment="Top"
                                   Orientation="Horizontal" Value="{Binding Path=ScrollBarValue}" Minimum="{Binding Path=SliderMinValue}"
                                   Maximum="{Binding Path=ScrollBarMaxValue}" LargeChange="1" SmallChange="1"/>
                        <Button Content="Add" HorizontalAlignment="Left" Margin="11,270,0,0" VerticalAlignment="Top" Width="75"
                Command="{Binding Path=AddCommand}"/>
                        <Button Content="Remove" HorizontalAlignment="Left" Margin="141,270,0,0" VerticalAlignment="Top" Width="75"
                Command="{Binding Path=RemoveCommand}"/>
                    </Grid>
                </TabItem>
                <TabItem Header="ListBox" d:DataContext="{d:DesignInstance {x:Type sample:ControlViewModel2}}">
                    <Grid UseLayoutRounding="True">
                        <ListBox HorizontalAlignment="Center" Height="100" VerticalAlignment="Top" Width="204" Margin="24,30,25,0"
                 FontSize="11.2"
                 ItemsSource="{Binding Persons}" DisplayMemberPath="Name"
                 SelectedItem="{Binding CurrentPerson, Mode=TwoWay}" />
                        <Label Content="Current :" HorizontalAlignment="Left" Margin="18,150,0,0" VerticalAlignment="Top" />
                        <Label Content="Count :" HorizontalAlignment="Left" Margin="18,180,0,0" VerticalAlignment="Top" />
                        <TextBox HorizontalAlignment="Left" Margin="88,155,0,0" Height="20" Width="103" TextWrapping="Wrap"
                 Text="{Binding CurrentPerson.Name, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" />
                        <TextBlock HorizontalAlignment="Left" Margin="98,185,0,0" Width="Auto" TextWrapping="Wrap"
                   Text="{Binding Persons.Count}" VerticalAlignment="Top" />
                        <Button Content="Add" Command="{Binding AddCommand}" HorizontalAlignment="Left" Margin="4,223,0,0"
                VerticalAlignment="Top" Width="75" Height="21" />
                        <Button Content="Remove" Command="{Binding RemoveCommand}" HorizontalAlignment="Left" Margin="84,223,0,0"
                VerticalAlignment="Top" Width="75" Height="21" />
                        <Button Content="Clear" Command="{Binding ClearCommand}" HorizontalAlignment="Left" Margin="164,223,0,0"
                VerticalAlignment="Top" Width="75" Height="21" />
                    </Grid>
                </TabItem>
                <TabItem Header="TreeView" d:DataContext="{d:DesignInstance {x:Type sample:ControlViewModel3}}">
                    <Grid>
                        <TreeView ItemsSource="{Binding Path=Groups}" Margin="0,0,0,148">
                            <TreeView.ItemTemplate>
                                <HierarchicalDataTemplate ItemsSource="{Binding Path=Persons}">
                                    <TextBlock Text="{Binding Path=Name}" Height="18"></TextBlock>
                                    <HierarchicalDataTemplate.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Path=Name}" Height="18"></TextBlock>
                                        </DataTemplate>
                                    </HierarchicalDataTemplate.ItemTemplate>
                                </HierarchicalDataTemplate>
                            </TreeView.ItemTemplate>
                        </TreeView>
                        <Button Content="Add Group" Margin="20,0,0,54" VerticalAlignment="Bottom"
                                Command="{Binding Path=AddGroupCommand}" Width="100" HorizontalAlignment="Left"/>
                        <Button Content="Remove Group" Margin="0,0,20,54" VerticalAlignment="Bottom"
                                Command="{Binding Path=RemoveGroupCommand}" Width="100" HorizontalAlignment="Right"/>
                        <Button Content="Add Person" Margin="20,0,0,26" VerticalAlignment="Bottom"
                                Command="{Binding Path=AddPersonCommand}" Width="100" HorizontalAlignment="Left"/>
                        <Button Content="Remove Person" Margin="0,0,20,26" VerticalAlignment="Bottom"
                                Command="{Binding Path=RemovePersonCommand}" Width="100" HorizontalAlignment="Right"/>
                        <TextBlock HorizontalAlignment="Left" Margin="20,200,0,0" TextWrapping="Wrap" 
                                   Text="Current Group:" VerticalAlignment="Top" />
                        <TextBlock HorizontalAlignment="Left" Margin="20,225,0,0" TextWrapping="Wrap" 
                        	Text="Current Person:" VerticalAlignment="Top"/>
                        <TextBox HorizontalAlignment="Left" Height="23" Margin="123,197,0,0" TextWrapping="Wrap" 
                                 Text="{Binding Path=CurrentGroup.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="120"/>
                        <TextBox HorizontalAlignment="Left" Height="23" Margin="124,225,0,0" TextWrapping="Wrap" 
                                 Text="{Binding Path=CurrentPerson.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="120"/>
                    </Grid>
                </TabItem>
                <TabItem Header="DataGrid" d:DataContext="{d:DesignInstance {x:Type sample:ControlViewModel4}}">
                    <Grid>
                        <DataGrid Height="212" Margin="-2,0,-4,0" VerticalAlignment="Top" ItemsSource="{Binding Path=Persons}"
                                  AutoGenerateColumns="False" SelectedItem="{Binding Path=CurrentPerson, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" />
                                <DataGridTextColumn Header="Age" Binding="{Binding Path=Age}" />
                                <DataGridTextColumn Header="HashCode" IsReadOnly="True" Binding="{Binding Converter={StaticResource HashCodeConverter}}" />
                            </DataGrid.Columns>
                        </DataGrid>
                        <Button Content="Add" Height="22" Width="75" Margin="37,258,141,33" Command="{Binding AddPersonCommand}"/>
                        <Button Content="Remove" Height="22" Width="75" Margin="150,258,28,33" Command="{Binding RemovePersonCommand}"/>
                    </Grid>
                </TabItem>
            </TabControl.Items>
        </TabControl>
    </Grid>
</UserControl>